using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Travel.UserControls
{
    public partial class MemberList : UserControl
    {       
        public MemberList()
        {
            InitializeComponent();
        }
        // The ListView Sorter
        private Travel.Library.ListViewItemComparer _lvwItemComparer = new Travel.Library.ListViewItemComparer();
       
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmbFormat_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbFormat.SelectedIndex == 0)
            {
                this.lvMember.View = View.LargeIcon;
            }            
            else
            {
                this.lvMember.View = View.Details;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MemberList_Load(object sender, EventArgs e)
        {
            cmbFormat.SelectedIndex = 1;
            this.lvMember.ListViewItemSorter = _lvwItemComparer;		
        }       

        private void lvUser_DoubleClick(object sender, EventArgs e)
        {
            Member objMember = new Member();
            objMember.Show();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Member objMember = new Member();
            objMember.Show();
        }
                
        private void lvUser_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                //ctxMenu.Show(lvMmeber, new Point(e.X, e.Y));
            }
        }

        private void lvMmeber_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            // Determine if clicked column is already the column that is being sorted.
            if (e.Column == _lvwItemComparer.SortColumn)
            {
                // Reverse the current sort direction for this column.
                if (_lvwItemComparer.Order == SortOrder.Ascending)
                {
                    _lvwItemComparer.Order = SortOrder.Descending;
                }
                else
                {
                    _lvwItemComparer.Order = SortOrder.Ascending;
                }
            }
            else
            {
                // Set the column number that is to be sorted; default to ascending.
                _lvwItemComparer.SortColumn = e.Column;
                _lvwItemComparer.Order = SortOrder.Ascending;
            }

            // Perform the sort with these new sort options.
            this.lvMember.Sort();

        }     
    }    
}
